from configparser import ConfigParser
from faker import Faker
faker = Faker(locale='zh_CN')
name=faker.name()

#实例化
config = ConfigParser()
config.read('config.ini',encoding='utf-8')
#查看
value = config.get("URL","dev_base_url")
value2 = config.get("DATABASE","dev_database")

# if __name__ == '__main__':
#     print(name)
#     print(value)

# #修改
# config.set("URL","dev_base_url","http://192.168.1.1")
# with open('config.ini','w',encoding='utf-8') as f:
#     config.write(f)
# value = config.get("URL","dev_base_url")
# print(value)


# #删除选项
# config.remove_option('URL','dev_base_url')
# with open('config.ini','w',encoding='utf-8') as f:
#     config.write(f)
# #删除节点
# config.remove_section('URL')
# with open('config.ini','w',encoding='utf-8') as f:
#     config.write(f)
# #批量删除
# [config.remove_section(i) for i in ['DATABASE','URL','NAME']]
# with open('config.ini','w',encoding='utf-8') as f:
#     config.write(f)

# # 查看所有节点
# print(config.sections())
#
# #查看摸个选是否在于节点，：True、False
# print(config.has_option('URL','dev_base_url'))